package com.pdd.service.Impl;

import com.pdd.beans.Address;
import com.pdd.dao.AddressMapper;
import com.pdd.service.AddressService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @创建时间: 2018/8/15 - 14:29
 * @编写人员: 丷教皇
 * @文件描述:
 */
@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    @Setter
    private AddressMapper addressMapper;

    /**
     * 新增地址
     *
     * @param address 地址对象
     * @return 返回成功失败
     */
    public boolean addAddress(Address address) {
        return addressMapper.insertAddress(address) > 0;
    }

    /**
     * 按编号删除地址
     *
     * @param id 地址编号
     * @return 返回成功失败
     */
    public boolean delAddress(int id) {
        return addressMapper.deleteAddress(id) > 0;
    }

    /**
     * 更新地址
     *
     * @param address 地址对象
     * @return 返回成功失败
     */
    public boolean updAddress(Address address) {
        return addressMapper.updateAddress(address) > 0;
    }

    /**
     * 按编号查询地址
     *
     * @param id 地址编号
     * @return 返回结果
     */
    public Address getById(int id) {
        return addressMapper.selectById(id);
    }

    /**
     * 查询所有地址
     *
     * @return 返回结果
     */
    public List<Address> getAll() {
        return addressMapper.selectAll();
    }
}
